package com.itheima.bos.service.impl;

import com.itheima.bos.dao.IDecidedzoneDao;
import com.itheima.bos.dao.ISubareaDao;
import com.itheima.bos.domain.Decidedzone;
import com.itheima.bos.domain.Subarea;
import com.itheima.bos.service.IDecidedzoneService;
import com.itheima.bos.utils.PageBean;
import com.itheima.crm.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Mr.King on 2017/3/13.
 */
@Service
@Transactional
public class DecidedzoneServiceImpl implements IDecidedzoneService{

    @Autowired
    private IDecidedzoneDao decidedzoneDao;

    @Autowired
    private ISubareaDao subareaDao;

    @Override
    public void save(Decidedzone model,String[] subareaid) {
        decidedzoneDao.save(model);

        for (String s : subareaid) {
            Subarea subarea = subareaDao.findById(s);
            subarea.setDecidedzone(model);
        }
    }

    @Override
    public void pagrQuery(PageBean pageBean) {
        decidedzoneDao.pageQuery(pageBean);
    }
}
